<?php
/**
 * Created by SonHA
 * User: Son Ha Anh (sonhaanh@vccorp.vn)
 * Date: 6/11/13
 * Time: 11:17 AM
 * To change this template use File | Settings | File Templates.
 */?>
<!doctype html>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title>Add and remove element</title>
    <script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
</head>
<body>
<a href="#" id="them">Thêm vào list</a><br />
<a href="#" id="xoa">Xóa 1 element trong list</a>
<ul id="themxoa">
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
</ul>
</body>
</html>
<script type="text/javascript">
    $(function() {
        var i = $('#themxoa li').size() + 1;
        $('a#them').click(function() {
            $('<li>' + i + '</li>').appendTo('ul#themxoa');
            i++;
//            $('<input type="text" name="test"+i+>').appendTo('ul#themxoa');
        });
        $('a#xoa').click(function() {
            $('#themxoa li:last').remove();
            i--;
        });
    })
</script>